echo > n-location.tmp

for app in `ls -1d */ | cut -d "/" -f1`
do
   result=$(cat root-app.txt | grep -x $app)
   if [ -z "$result" ]; then 
      cat n-app.txt | sed  "s|{app}|$app|g" >> n-location.tmp
   fi
done

txt=""
while read line
do 
  txt="${txt}\n${line}"
done < n-location.tmp

cat nginx.txt | sed "s|{apps}|$txt|"  > nginx.conf

